import * as proxy from '../proxy';
import ServiceBase from '../base';

const GET_JOB = '/jobs';
const JOB = '/job';

class JobService extends ServiceBase {
    public createJob = (options) => {
        let promise = super.post({
            url: GET_JOB,
            data: options,
        });
        return proxy.httpResultProxy(promise);
    };

    public createJobFromCompare = (options) => {
        let promise = super.post({
            url: JOB,
            data: options,
        });
        return proxy.httpResultProxy(promise);
    };

    public getJob = (options) => {
        let promise = super.get({
            url: GET_JOB + `?urn=${options.urn}`,
        });
        return proxy.httpResultProxy(promise);
    };

    public getBatchJob = (options) => {
        let promise = super.post({
            url: GET_JOB + `/batchget`,
            data: options,
        });
        return proxy.httpResultProxy(promise);
    };

    public createCompare = (options) => {
        const promise = super.post({
            data: options,
            url: JOB + '/compare',
        });
        return proxy.httpResultProxy(promise);
    };
    // fileUrn=&orderBy=createAt&direction=desc

    public getCompare = (options) => {
        const promise = super.get({
            url: JOB + `/compares?fileUrn=${options.fileUrn}&direction=${options.direction}`,
        });
        return proxy.httpResultProxy(promise);
    };
}

export {JobService};
